<template>
  <el-dialog
    title="房屋踏查"
    :visible.sync="dialogVisible"
    width="50%"
    :before-close="handleClose"
  >
    <div
      style="display: flex; align-items: center; justify-content: space-between"
    >
      <el-button
        type="primary"
        icon="el-icon-download"
        style="margin-bottom: 10px"
        @click="handleExport"
        >导出EXCEL</el-button
      >
      <div>
        <el-select
          v-model="type"
          placeholder="房屋类型"
          clearable
          style="margin-right: 10px"
          @change="typeChange"
        >
          <el-option
            v-for="dict in typeList"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
        <el-select
          v-model="mode"
          placeholder="列表类型"
          clearable
          @change="typeChange"
        >
          <el-option
            v-for="dict in modeList"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </div>
    </div>
    <el-table v-loading="loading" :data="list">
      <el-table-column label="地区名" align="center" prop="dqm" />
      <el-table-column label="房屋名称" align="center" prop="fwmc" />
      <el-table-column label="房屋所在地" align="center" prop="fwszd" />
      <el-table-column label="房屋所在村社" align="center" prop="fwszcs" />
      <el-table-column label="上次踏查时间" align="center" prop="sctcsj" />
      <el-table-column label="超期时间" align="center" prop="cqsj" />
      <el-table-column label="踏查人" align="center" prop="tcr" />
      <!-- <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['msg:dcwjTk:edit']"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            >修改</el-button
          >
          <el-button
            v-hasPermi="['msg:dcwjTk:remove']"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column> -->
    </el-table>
    <pagination
      v-show="false"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </el-dialog>
</template>

<script>
import { getDetail } from "@/api/earlyWarning/fwtc";
export default {
  data() {
    return {
      dialogVisible: false,
      total: 0,
      list: [],
      type: "0",
      typeList: [
        { label: "自主房屋", value: "0" },
        { label: "非自主房屋", value: "1" },
      ],
      mode: "0",
      modeList: [
        { label: "即将超期", value: "0" },
        { label: "已超期", value: "1" },
      ],
      loading: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  methods: {
    openModal() {
      this.dialogVisible = true;
      this.getList();
    },
    typeChange() {
      this.getList();
    },
    getList() {
      this.loading = true;
      getDetail({
        mode: this.mode,
        type: this.type,
      }).then((response) => {
        this.loading = false;
        this.list = response.data;
      });
    },
    handleClose(done) {
      done();
    },
    handleExport() {
      this.download(
        "warn/fwtcyj/export",
        {
          mode: this.mode,
          type: this.type,
        },
        `房屋踏查_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
